//
//  TripCityCCell.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/10/23.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class TripCityCCell: UICollectionViewCell {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var imageViewH: NSLayoutConstraint!
    /// 0为 景点 1为城市
    var type:Int = 0

    override var isSelected: Bool {
        
        didSet {
            
            if type == 0 {
                
                return
            }
            
            self.imageView.layer.borderWidth = isSelected ? 2 : 0
            self.imageView.layer.borderColor = KThemeColor.cgColor
            
            self.titleLabel.textColor = isSelected ? KThemeColor : kTitleColor
        }
    }

    override func layoutSubviews() {
        
        super.layoutSubviews()
        
        self.imageViewH.constant = type == 1 ? frame.width : frame.width * 176 / 256
        
        self.imageView.layer.cornerRadius = type == 1 ? frame.width / 2.0 : 5
    }
    
    var city:City? {
        
        didSet {
            
            self.imageView.setImage(string: city?.pic, placeholder: UIImage(named:"placeholder_squ")!)
            self.titleLabel.text = city?.cityName
        }
    }
    
    var calendar:Calendar? {
        
        didSet {
            
            self.imageView.setImage(string: calendar?.pictureArray?.first, placeholder: UIImage(named:"placeholder_squ")!)
            self.titleLabel.text = calendar?.title
        }
    }
}
